package com.ham.mud.items;

import com.ham.mud.LookAtAble;
import com.ham.mud.ServerConnection;

/**
 * Created by hlucas on Jun 21, 2011 at 12:55:51 PM
 */
public class Item implements LookAtAble {
    int price = 1;
    
    String fileName;
    String name;
    String shortDescription;
    String longDescription;
    String[] targetingKeys;
    String itemAffects;

    boolean wearable;
    EquipSlot wornAt;

    public Item() {
    }

    public Item(String fileName, String name, String shortDescription, String longDescription, String[] targetingKeys) {
        this.fileName = fileName;
        this.name = name;
        this.shortDescription = shortDescription;
        this.longDescription = longDescription;
        this.targetingKeys = targetingKeys;
        this.itemAffects = getItemAffects();
    }

    public String getAffects() {
        String affects = getItemAffects();
        if(affects == null || affects.equals("")) {
            return "";
        }
        return " " + affects;
    }

    protected String getItemAffects() {
        return "";
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortDescription() {
        return shortDescription;
    }

    public void setShortDescription(String shortDescription) {
        this.shortDescription = shortDescription;
    }

    public String getLongDescription() {
        return longDescription;
    }

    public void setLongDescription(String longDescription) {
        this.longDescription = longDescription;
    }

    public String[] getTargetingKeys() {
        return targetingKeys;
    }

    public void setTargetingKeys(String[] targetingKeys) {
        this.targetingKeys = targetingKeys;
    }

    public boolean isWearable() {
        return wearable;
    }

    public void setWearable(boolean wearable) {
        this.wearable = wearable;
    }

    public EquipSlot getWornAt() {
        return wornAt;
    }

    public void setWornAt(EquipSlot wornAt) {
        this.wornAt = wornAt;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public void display(ServerConnection connection) {
        connection.printSolo(getLongDescription());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Item item = (Item) o;

        return this.getFileName().equals(item.getFileName());
    }
}
